package com.vhall.component.controller.gift.admin;

import com.vhall.component.entity.gift.dto.GiftDataDTO;
import com.vhall.component.entity.gift.dto.GiftListDataDTO;
import com.vhall.component.entity.gift.vo.*;
import com.vhall.component.entity.page.vo.PageVO;
import com.vhall.component.plugin.common.annotation.TokenAuth;
import com.vhall.component.plugin.common.enums.OperateTypeEnum;
import com.vhall.component.service.annotation.OperateLog;
import com.vhall.component.service.gift.AdmGiftService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 表情管理
 * AdmGiftController-admin端的表情管理 前端控制器
 *
 * @author xing.wang
 * @date 2022/10/9
 */
@RestController
@RequestMapping("/v4/gift/admin")
@RequiredArgsConstructor
@Tag(name = "表情管理-管理端")
public class AdmGiftController {
    private final AdmGiftService service;

    /**
     * 表情新增
     *
     * @param vo 参数
     * @return 表情对象
     */
    @PostMapping(value = "/create")
//    @TokenAuth("sys:gift:create")
    @TokenAuth
    @OperateLog(type = OperateTypeEnum.CREATE, name = "表情新增")
    public GiftDataDTO create(@Validated GiftCreateVO vo) {
        return service.create(vo);
    }

    /**
     * 表情编辑
     *
     * @param vo 参数
     * @return 是否编辑成功
     */
    @PostMapping(value = "/update")
//    @TokenAuth("sys:gift:update")
    @TokenAuth
    @OperateLog(type = OperateTypeEnum.UPDATE, name = "表情编辑")
    public Boolean update(@Validated GiftUpdateVO vo) {
        return service.update(vo);
    }

    /**
     * 表情删除
     *
     * @param vo 参数
     * @return 是否删除成功
     */
    @PostMapping(value = "/delete")
//    @TokenAuth("sys:gift:delete")
    @TokenAuth
    @OperateLog(type = OperateTypeEnum.DELETE, name = "表情删除")
    public Boolean delete(@Validated GiftDeleteVO vo) {
        return service.delete(vo);
    }

    /**
     * 表情分页列表
     *
     * @param vo 参数
     * @return 表情分页列表
     */
    @PostMapping(value = "/list")
//    @TokenAuth("sys:gift:list")
    @TokenAuth
    public PageVO<GiftListDataDTO> list(@Validated GiftListVO vo) {
        return service.list(vo);
    }


    /**
     * 表情排序
     */
    @PostMapping(value = "/gift_sort")
    @TokenAuth
    @OperateLog(type = OperateTypeEnum.UPDATE, name = "表情排序")
    public Boolean giftSort(@Validated GiftSortVO vo) {
        return service.giftSort(vo);
    }
}
